package com.frikinet.lifeguard.tests;

import org.apache.log4j.PropertyConfigurator;

import com.frikinet.lifeguard.model.Post;
import com.frikinet.lifeguard.util.HibernateUtil;

public class HibernateTest
{
	public static void main(String args[])
	{
		PropertyConfigurator.configure(HibernateTest.class.getClassLoader().getResource("log4.properties"));
		
		Post post = new Post();
		post.setTitle("Titulo");
		post.setText("Texto");
		
		HibernateUtil.saveOrUpdate(post);
		
		for(Post p: HibernateUtil.getElements(Post.class))
		{
			System.out.println(String.format("%d: %s", p.getId(), p.getTitle()));
		}
		
		HibernateUtil.getSession().createSQLQuery("SHUTDOWN COMPACT").executeUpdate();
	}
}
